<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <link th:href="@{/erp/assets/css/bootstrap.min.css}" rel="stylesheet"/>
        <link rel="stylesheet" th:href="@{/erp/css/style.css}"/>
        <link rel="stylesheet" th:href="@{/erp/assets/css/ace.min.css}"/>
        <link rel="stylesheet" th:href="@{/erp/assets/css/font-awesome.min.css}"/>
        <script th:src="@{/erp/assets/js/jquery.min.js}"></script>
        <script th:src="@{/erp/assets/js/bootstrap.min.js}"></script>
        <script th:src="@{/erp/assets/js/jquery.dataTables.min.js}"></script>
        <script th:src="@{/erp/assets/js/jquery.dataTables.bootstrap.js}"></script>
        <script th:src="@{/erp/assets/layer/layer.js}" type="text/javascript"></script>
        <title>我的供应商</title>
    </head>

    <body>
        <div class="margin clearfix">
            <div class="" id="Other_Management">
                <div class="search_style">

                    <form id="queryForm" action="/supplier/my_supplier" method="post">
                        <ul class="search_content clearfix">
                            <li><label class="l_f" id="area" >选择地区：</label><input class="width-20"name="companyAddress" type="hidden"  id="address"  /></li>
                            <li><label class="l_f">企业名称:</label><input name="sname" type="text"
                                                                       style=" width:260px"/></li>
                            &nbsp;
                            <li style="width:100px;">
                                <button id="btn" type="button" class="btn_search"><i class="fa fa-search"></i>查询</button>
                            </li>
                        </ul>
                    </form>
                    <br/>
                </div>
                <div class="Store_Introduction">
                    <div class="list_style">
                        <table class="table table-striped table-bordered table-hover" id="sample-table">
                            <thead>
                            <tr>

                                <th>序号</th>
                                <th>企业名称</th>
                                <th>区域</th>
                                <th>主要经营</th>
                                <th>公司邮箱</th>
                                <th>备注</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                        </table>
                    </div>
                </div>
            </div>
        </div>
        </div>

    </body>
    <script th:src="@{/area/area.js}"></script>
</html>
<script>
    jQuery(function ($) {
        var oTable1 = $('#sample-table').dataTable({
            iDisplayLength: 5, //默认显示的记录数
            aLengthMenu: [5, 10, 15, 20, 50, 100], //更改显示记录数选项
            "autoWidth": true,
            "ordering": false,
            bFilter: false, //是否启动过滤、搜索功能
            "bStateSave": false,//状态保存
            "serverSide": true,		//打开服务器模式
            "ajax": {
                "url": "/supplier/my_supplier",
                "type": "POST",
                dataSrc: "data",
                data: function (d) {
                    var param = {};
                    param.draw = d.draw;
                    param.start = d.start;
                    param.length = d.length;
                    var formData = $("#queryForm").serializeArray();//把form里面的数据序列化成数组
                    formData.forEach(function (e) {
                        param[e.name] = e.value;
                    });
                    return param;//自定义需要传递的参数。
                },
            },
            "columns": [
                {"data": 'id'},
                {"data": 'companyName'},
                {"data": 'companyAddress'},
                {"data": 'companyRange'},
                {"data": 'companyEmail'},
                {"data": 'companyDescribe'},
                {"data": null}
            ], "columnDefs": [
                {
                    // targets用于指定操作的列，从第0列开始，-1为最后一列，这里第六列
                    // return后边是我们希望在指定列填入的按钮代码
                    "targets": -1,
                    "render": function (data, type, full, meta) {
                        return /*<![CDATA[*/"<a title='订购' id = 'order'  class='btn btn-xs btn-info'><i class='fa'>订购</i></a>"/*]]>*/
                    }
                }
            ]
        });

        $("table tbody").on("click", "#order", function () {
            //获取行
            var row = $("table tr").index($(this).closest("tr"));
            //获取某列（从0列开始计数）的值
            var id = $("table").find("tr").eq(row).find("td").eq(0).text();
            window.location.href = "/supplier/online_order_xdPage?companyId=" + id;
        });

        $("#btn").click(function () {
            var v1 = $('#area').children(":eq(0)").val()
            var v2 = $('#area').children(":eq(1)").val();
            var v3 = $('#area').children(":eq(2)").val();
            if (v1=="-1"){
                v1=""
            }
            if (v2=="-1"){
                v2=""
            }
            if (v3=="-1"){
                v3=""
            }
            var address = v1+v2+v3;
            $('#address').val(address);
            oTable1.fnDraw();
        })

    })
</script>
